home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / pgp23src.zip / PGPMAIL.MH < prev    next >
Text File  |  1993-05-14  |  2KB  |  56 lines

  1. Here's a start for mh + MIME users: an "editor" that runs out of the MH
  2. "What now?" prompt, and PGP encodes your message in a nice mhn-processable
  3. format.  Note that this works only on MH 6.7.2-MIME+mtr or later.
  4.  
  5. Call this script "pgpedit" and make links to it called: pgpe, pgpes, pgpk,
  6. pgka.
  7.  
  8. After you're done writing your message, type "edit pgpe" at the What now?
  9. prompt, it will try to figure out who you're sending to, encode with their
  10. key if you have it, and format it for MHN.  Then type "edit mhn" and voila
  11. your message is ready to go.  The type is "text/x-pgp" and needs an
  12. .mh_profile line like:
  13.  
  14. mhn-show-text/x-pgp: pgp -m %F
  15.  
  16. You can call it by different names for different options, notable "pgpk" to
  17. send someone your public key, or "pgpka" to send the whole keyring.
  18. Anyway, here's the script.
  19.  
  20. #!/bin/sh
  21.  
  22. case `basename $0` in
  23.     pgpes) opt="-feast" ;;
  24.     pgps) opt="-staf +clearsig=on" ;;
  25.     pgpe) opt="-feat" ;;
  26.     pgpka) pgp -kxa "" pubkey$$
  27.                 (echo '#<text/x-pgp';cat pubkey$$.asc;echo '#') >> $*
  28.                 rm -f pubkey$$.asc
  29.                 exit 0 ;;
  30.     pgpk)    pgp -kxa $USER pubkey$$
  31.         (echo '#<text/x-pgp';cat pubkey$$.asc;echo '#') >> $* 
  32.         rm -f pubkey$$.asc 
  33.         exit 0 ;;
  34. esac
  35.  
  36. if head -20 $* | grep -s '^--------$' ; then
  37.     sed -ne '1,/^--------$/p' $* > header$$
  38.     sed -e '1,/^--------$/d' $* > body$$
  39. else
  40.     sed -ne '1,/^$/p' $* > header$$
  41.     sed -e '1,/^$/d' $* > body$$
  42. fi
  43.  
  44. to=`sed -ne 's/^[tT]o: //p' header$$`
  45.  
  46. if [ -n "$to" ] ; then
  47.     if pgp -kv "$to" 2>&1 | grep -s '^pub' ; then
  48.         echo Using public key for $to.
  49.         opt="$opt $to"
  50.     fi
  51. fi
  52.  
  53. (cat header$$;echo '#<text/x-pgp';pgp $opt < body$$;echo '#')  > $*
  54. rm -f header$$ body$$
  55. # End of script
  56.